﻿// ----------------------------------------------------------------
// taken from: https://buefy.org/documentation/carousel/
// ----------------------------------------------------------------

$carousel-min-height: 120px !default;

$carousel-arrow-background: var(--b-theme-white, $white) !default;
$carousel-arrow-color: var(--b-theme-primary, $primary) !default;
$carousel-arrow-icon-spaced: 1.5rem !default;
$carousel-arrow-top: 50% !default;

$carousel-indicator-background: rgba($black, 0.50) !default;
$carousel-indicator-border: var(--b-theme-white, $white) !default;
$carousel-indicator-color: var(--b-theme-primary, $primary) !default;
$carousel-indicator-spaced: .5rem !default;

$carousel-overlay-background: rgba($black, 0.86) !default;
$carousel-overlay-z: 40 !default;

%unselectable {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.carousel {
    @extend %unselectable;
    min-height: $carousel-min-height;
    position: relative;

    &.is-overlay {
        background-color: $carousel-overlay-background;
        align-items: center;
        flex-direction: column;
        justify-content: center;
        display: flex;
        max-height: 100vh;
        position: fixed;
        z-index: $carousel-overlay-z;

        .carousel-item img {
            cursor: default;
        }

        .carousel-indicator.has-background {
            background: transparent;
        }
    }

    .progress {
        border-radius: 2px;
        height: 0.25rem;
        margin-bottom: 0;
    }

    .carousel-items {
        position: relative;
        display: flex;
        overflow: hidden;
        width: 100%;

        &:hover .carousel-arrow.is-hovered {
            @include tablet {
                opacity: 1;
            }
        }

        .carousel-item {
            flex-shrink: 0;
            width: 100%;

            &-hidden {
                display: none;
            }
        }
    }

    .carousel-pause {
        pointer-events: none;
        position: absolute;
        top: 0;
        right: 0.15rem;
        z-index: 1;
    }

    .carousel-indicator {
        width: 100%;
        padding: $carousel-indicator-spaced;
        display: flex;
        align-items: center;
        justify-content: center;

        &.has-background {
            background: $carousel-indicator-background;
        }

        &.has-custom {
            flex-wrap: nowrap;
            justify-content: flex-start;
            @include overflow-touch;
            overflow: hidden;
            overflow-x: auto;

            &.is-small .indicator-item {
                flex: 1 0 10%;
            }

            &.is-medium .indicator-item {
                flex: 1 0 16.66667%;
            }
        }

        &.is-inside {
            position: absolute;

            &.is-bottom {
                bottom: 0;
            }

            &.is-top {
                top: 0;
            }
        }

        .indicator-item {
            &:not(:last-child) {
                margin-right: $carousel-indicator-spaced;
            }

            &.is-active .indicator-style,
            .indicator-style:hover {
                background: $carousel-indicator-color;
                border: 1px solid $carousel-indicator-border;
            }

            .indicator-style {
                display: block;
                border: 1px solid $carousel-indicator-color;
                background: $carousel-indicator-border;
                outline: none;
                transition: $speed-slow $easing;

                &.is-boxes {
                    height: 10px;
                    width: 10px;
                }

                &.is-dots {
                    border-radius: 10px;
                    height: 10px;
                    width: 10px;
                }

                &.is-lines {
                    height: 5px;
                    width: 25px;
                }
            }
        }
    }
}

.carousel-list {
    @extend %unselectable;
    position: relative;
    overflow: hidden;
    width: 100%;

    &.has-shadow {
        box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.25);
    }

    &:hover .carousel-arrow.is-hovered {
        @include tablet {
            opacity: 1;
        }
    }

    .carousel-slides {
        position: relative;
        display: flex;
        width: 100%;

        &:not(.is-dragging) {
            transition: all $speed-slower ease-out 0s;
        }

        &.has-grayscale {
            .carousel-slide {
                img {
                    filter: grayscale(100%);
                }

                &.is-active img {
                    filter: grayscale(0%);
                }
            }
        }

        &.has-opacity {
            .carousel-slide {
                img {
                    opacity: 0.25
                }

                &.is-active img {
                    opacity: 1
                }
            }
        }

        .carousel-slide {
            border: 2px solid transparent;
            flex-shrink: 0;
        }
    }
}

.carousel-arrow {
    transition: $speed-slow $easing;

    &.is-hovered {
        opacity: 0;
    }

    .icon {
        background: $carousel-arrow-background;
        color: $carousel-arrow-color;
        cursor: pointer;
        border: 1px solid $carousel-arrow-background;
        border-radius: $radius-rounded;
        outline: 0;

        &:hover {
            border: 1px solid $carousel-arrow-color;
            opacity: 1;
        }

        &.has-icons-left,
        &.has-icons-right {
            position: absolute;
            top: $carousel-arrow-top;
            transform: translateY(-$carousel-arrow-top);
            z-index: 1;
        }

        &.has-icons-left {
            left: $carousel-arrow-icon-spaced;
        }

        &.has-icons-right {
            right: $carousel-arrow-icon-spaced;
        }
    }
}
